<?php
class DedeEditor
{
	var $InstanceName ;
	var $BasePath ;
	var $Width ;
	var $Height ;
	var $ToolbarSet ;
	var $Value ;

	function __construct( $instanceName )
	{
		$this->InstanceName	= $instanceName ;
	}
	
	function FCKeditor( $instanceName )
	{
		$this->__construct( $instanceName );
	}

	function Create()
	{
		echo $this->CreateHtml() ;
	}
	
	function CreateHtml()
	{
		if(defined('PLUGINS'))
		{
			$KE_fystr = '<hr style="color:#999;height:10px" name="page"/>';
		}
		else
		{
			$KE_fystr = '#p#分页#e#';
		}
		
		if($this->ToolbarSet == 'basic')
		{
			$allowFileManager = 'true';
		}
		else
		{
			$allowFileManager = 'false';
		}
		$str = '<textarea id="'.$this->InstanceName.'" name="'.$this->InstanceName.'" style="width:'.$this->Width.';height:'.$this->Height.'px;visibility:hidden">'.$this->Value.'</textarea>'."\r\n";
		$str .= '<script charset="utf-8" src="'.$this->BasePath.'kindeditor-min.js"></script>'."\r\n";
		$str .= "<script>
		KE.lang['fy'] = '分页';
		KE.plugin['fy'] = {click : function(id) {KE.insertHtml('".$this->InstanceName."', '".$KE_fystr."');}};	
		KE.show({id : '".$this->InstanceName."' ,
				items:['source', '|', 'cut', 'copy', 'paste','plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright','justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript','superscript', 'undo', 'redo', 'fullscreen', '-','title', 'fontname', 'fontsize', '|', 'bold','italic', 'underline', 'strikethrough', 'removeformat', 'textcolor', 'bgcolor', '|', 'image','flash', 'media', 'advtable', 'hr', 'emoticons', 'link', 'unlink','fy'],
				allowFileManager:".$allowFileManager.",
				imageUploadJson:'{$this->BasePath}dede_image.php?dopost=upload',
				fileManagerJson:'{$this->BasePath}dede_image.php?dopost=manage&',
				beforeCreate : function(id) {},
				afterCreate : function(id) {EditInit();},
				afterDialogCreate : function(id) {}
		});
		EditInit = function (){
			var KEhtml = KE.html('{$this->InstanceName}');
			KEhtml = KEhtml.replace(/#p#page#e#/ig,\"<hr style='height:10px;color:#999;' name='page' />\");
			KE.html('{$this->InstanceName}',KEhtml);
		}
		</script>";
		return $str;
	}
}
?>